package guowenlong.golf.ui.login;

import guowenlong.golf.C;
import guowenlong.golf.entity.LoginEntity;
import rx.Observer;

/**
 * des   : 描述 author: Gavin email : guowenlong20000@gmail.com time  : 2016年08月31日 下午 5:19.
 */
public class LoginPresenter extends LoginContract.Presenter {

  @Override
  public void onStart() {
  }

  @Override
  public void login(String phone, String password) {
    mRxManager.add(mModel.login(phone, password).subscribe(new Observer<LoginEntity>() {
      @Override
      public void onCompleted() {

      }

      @Override
      public void onError(Throwable e) {

      }

      @Override
      public void onNext(LoginEntity loginEntity) {
        if (loginEntity.getStatus() == C.RESULT_OK) {
          mView.loginSuccess(loginEntity);
        } else if (loginEntity.getStatus() == C.RESULT_ERROR) {
          mView.loginError(loginEntity);
        }
      }
    }));
  }
}
